/*
# 堆、栈、静态全局区的存储
//对于栈，陷入栈的在底部，栈的空间有限
//对于堆，地址为递增值，最大空间受物理内存限制
*/
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<string.h>

int  a = 111; //全局初始化区
char b = 'b';
char d = 'd';

char *p1;  //全局未初始化区

int main()
{
	char s[]  = "s=abcd";  //栈
	char s1[] = "s1s1s1s1"; //栈
	char s2[] = "s2s2s2s2"; //栈

	char *p2; //栈
	char *p3 = "123456"; // 123456\0在常量区，p3在栈
	static int c =222 ; //全局(静态)初始化区

	p1 = (char *)malloc(10); //堆
	p2 = (char *)malloc(20); //堆

	char *p4 = (char *)malloc(10); //堆
	char *p5 = (char *)malloc(10); //堆
	char *p6 = (char *)malloc(10); //堆
	p4 = "p44444444";
	p5 = "p55555555";
	p6 = "p66666666";
	strcpy( p1, "123456"); // 123456\0在常量区，编译器可能会将它和p3所指向的123456\0优化成同一个地方。

	free(p1);
	free(p2);
	free(p5);
	free(p5);
	free(p6);	
	return 0;
}
